﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using PowerCreator.LMS.Common.Script;
using PowerCreator.LMS.Web.Task;
using PowerCreator.LMS.Task.Entity;

public partial class sysadmin_TaskManager_AddEvaluate : System.Web.UI.Page
{
    EvaluateManag objEvaluateManag = new EvaluateManag();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int EvateID = int.Parse(Request.Params["id"].ToString());
                ViewState["EvateID"] = EvateID;
                ShowInfo(EvateID);
            }
        }
    }
    private void ShowInfo(int EvateID)
    {

        Evaluate model = objEvaluateManag.Load(EvateID);

        //this.lblEvateID.Text = model.EvateID.ToString();
        this.txtEvateName.Text = model.EvateName;
        if (model.EvateShowState == 1)
        {
            rdbtnEvateShowStateOK.Checked = true;
        }
        else
        {
            rdbtnEvateShowStateNO.Checked = true;
        }
        this.txtEvateRemark.Text = model.EvateRemark;
        this.txtEvateComposer.Text = model.EvateComposer;
        //this.txtEvateScore.Text = model.EvateScore.ToString();
        //this.txtEvateCreateTime.Text = model.EvateCreateTime.ToString();
        //this.txtFKEvateCreateID.Text = model.FKEvateCreateID.ToString();

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {

        string EvateName = this.txtEvateName.Text;
        int EvateShowState = 1;
        string EvateRemark = this.txtEvateRemark.Text;
        string EvateComposer = this.txtEvateComposer.Text;
        int EvateScore = 0;
        DateTime EvateCreateTime = DateTime.Now;
        int FKEvateCreateID = 10000;

        Evaluate model = new Evaluate();
        if (ViewState["EvateID"] != null)
        {
            model = objEvaluateManag.Load(int.Parse(ViewState["EvateID"].ToString()));
        }
        if (!rdbtnEvateShowStateOK.Checked)
            EvateShowState = 0;
        model.EvateName = EvateName;
        model.EvateShowState = EvateShowState;
        model.EvateRemark = EvateRemark;
        model.EvateComposer = EvateComposer;
        model.EvateScore = EvateScore;
        model.EvateCreateTime = EvateCreateTime;
        model.FKEvateCreateID = FKEvateCreateID;
        
        bool result;
        if (ViewState["EvateID"] == null)
        {
            result = objEvaluateManag.AddNew(model);
        }
        else
        {
            result = objEvaluateManag.Update(model);
        }
        if (result)
        {
            Script.RedirectURL("EvaluateManager.aspx");
        }
    }
    protected void btnReset_Click(object sender, EventArgs e)
    {
        Script.RedirectURL("EvaluateManager.aspx");
    }
}
